<?php


class Answers extends CActiveRecord
{
    public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
	
	public function tableName()
	{
		return 'tb_answers';
	}

          
          public function attributeLabels()
	{
		return array(
			'ans_id' => 'รหัส',
			'ans_name' => 'ชื่อ',
			'ques_id' => 'ไอดี คำถาม',
			'id' => 'ID',
			'ans_created' => 'วันที่บันทึก',
		);
	}
                         	
	public function rules()
	{
		
		return array(
			array('ans_name, ques_id, id, ans_created', 'required'),
			array('ques_id, id', 'numerical', 'integerOnly'=>true),
			array('ans_name', 'length', 'max'=>9),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('ans_id, ans_name, ques_id, id, ans_created', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
                return array();
		
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
		
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ans_id',$this->ans_id);
		$criteria->compare('ans_name',$this->ans_name,true);
		$criteria->compare('ques_id',$this->ques_id);
		$criteria->compare('id',$this->id);
		$criteria->compare('ans_created',$this->ans_created,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}


	
          
          
          
}
